<?php namespace App\Service\Admin;


use App\Model\Admin\UserRoleModel;
use App\Service\BaseService;

/**
 * 人员角色关联管理-服务类
 * @author LZH
 * @since: 2021/08/12
 * Class UserRoleService
 */
class UserRoleService extends BaseService
{
    /**
     * 构造函数
     * LevelService constructor.
     */
    public function __construct()
    {
        $this->model = new UserRoleModel();
        parent::__construct();
    }
	
	/**
     * 获取数据列表
     * @return array
     * @since 2021/08/12
     * @author LZH
     */
    public function getList()
    {
        $param = $this->getRequestParam();

        // 查询条件
        $map = [];
		

        return parent::getList($map);
    }

    /**
     * 获取用户角色列表
     * @param $userId
     * @return mixed
     * @author LZH
     */
    public function getUserRoleList($userId)
    {
        return $this->model->getUserRoleList($userId);
    }

    /**
     * 删除用户角色关系数据
     */
    public function deleteUserRole($userId)
    {
        return $this->model->softDestroyByUserId($userId);
    }

    /**
     * 批量插入用户角色关系数据
     */
    public function insertUserRole($userId, $roleIds)
    {
        if (!empty($roleIds)) {
            $list = [];
            foreach ($roleIds as $val) {
                $data = [
                    'user_id' => $userId,
                    'role_id' => $val,
                ];
                $list[] = $data;
            }
            return $this->model->saveAll($list);
        }
        return false;
    }


}